import React from 'react'
import OrderTable, {OrderTableProps} from "./OrderTable";
import {castFilterValue} from "../utils/AntdTableUtils";
import {TablePaginationConfig} from "antd";
import {OrderSummary} from "../apis/OrderApi";
import {SorterResult} from "antd/es/table/interface";

export interface OnlinePaginationOrderTableProps extends OrderTableProps {
    onConditionChange: (condition: QueryOrderTableDataCondition) => void
}

type T = OrderSummary

export interface QueryOrderTableDataCondition {
    name?: string
    brand?: string
    category?: string
    model?: string
    pagination: TablePaginationConfig,
    sorter: SorterResult<T> | SorterResult<T>[]
}

const OnlinePaginationOrderTable: React.FC<OnlinePaginationOrderTableProps> = (props) => {
    return <>
        <OrderTable {...props} onChange={(pagination, filters, sorter, _, ) => {
            props.onConditionChange({
                name: castFilterValue((filters.name)),
                model: castFilterValue((filters.model)),
                category: castFilterValue((filters.category)),
                brand: castFilterValue((filters.brand)),
                sorter,
                pagination,
            })
        }}>

        </OrderTable>
    </>
}

export default OnlinePaginationOrderTable


